# load libraries ----
library(tidyverse)
library(here)
library(brms)
# load functions ----
r_function_list <- list.files(
path = here("R", "00_functions"),
pattern = "R$",
full.names = TRUE
)
purrr::walk(r_function_list, source)
# load and prepare data ----
# get file names
r_file_list <- list.files(
path = here::here("02_data", "02_cleaned", "02_aggregated", "01_rds"),
pattern = "rds$",
full.names = TRUE
)
# read files and rename items in list with file names
data <- r_file_list %>%
map(read_rds)
names(data) <- r_file_list %>%
sub(".*/", "", .) %>%
substr(., 1, nchar(.)-4)
# load in demographic data and games played data
data$demo <- read_rds(
here("02_data", "02_cleaned", "01_multilevel", "01_rds", "demographics.rds")
)
data$games_played <- read_rds(
here("02_data", "02_cleaned", "01_multilevel", "01_rds", "games_played_wider.rds")
)
# load models ----
models_list <- list.files(
path = here::here("04_analysis", "01b_model_summaries"),
pattern = "rds$",
full.names = TRUE
)
models <- models_list %>%
map(read_rds)
names(models) <- models_list %>%
sub(".*/", "", .) %>%
substr(., 1, nchar(.)-4)
# load hypothesis tests ----
hypothesis_lists <- list.files(
path = here::here("04_analysis", "02_hypotheses"),
pattern = "csv$",
full.names = TRUE
)
hypotheses <- hypothesis_lists %>%
map(read_csv)
names(hypotheses) <- hypothesis_lists %>%
sub(".*/", "", .) %>%
substr(., 1, nchar(.)-4)
# read in all plots ----
plots_dir <- list.files(
path = here::here("03_plots"),
pattern = "png$",
full.names = TRUE
)
We used R version 3.6.3 (2020-02-29) and the R-packages tidyverse (version 1.3.0), here (version 0.1), brms (version 2.12.0), modelr (version0.1.6), tidybayes (version 2.0.1), and patchwork (version 1.0.0) for data preparation and analysis.
We took the data from the DAS questionnaire ratings before and after lockdown and combined these with hours played before and after lockdown.
Given the data are generated from three Likert-style questionnaire responses per subscale, added together and multiplied by two, responses are thus strictly positive integers. This required fitting the data to cumulative models using a logit link function.
We fitted these models separately for each subscale of the DAS using the brm function in brms, estimating the effect of hours played in video games, time (pre- and post-lockdown), and the interaction between them. The effect of time was sum-coded (i.e. before = 1 and after = -1), such that the fixed effect of time represents the average effect of time across the range of hours played (i.e. a main effect). All models contained random intercepts per participant. Models used a \(Normal(0, 50)\) prior on the intercept, a \(Normal(0, 5)\) prior on the slope terms, and an \(Exponential(1)\) prior on the standard deviation term.
We present the fixed effect parameter estimates below on the log scale followed by the same parameter estimates backtransformed to the natural (i.e. rating) scale. For each model, we present posterior predictions from the model. We evaluate the evidence in support for an effect for each fixed factor using Bayes factors calculated using the Savage Savage-Dickey density ratio with the hypothesis function in brms.
Below we show spaghetti plots showing the predictions for each model for the effect of hours played within each subscale and time period on DAS outcomes.
knitr::include_graphics(plots_dir[str_detect(plots_dir, "das_predictions.png")])
On the logit scale, model fixed effects parameter estimates are as follows:
as.data.frame(models$das_d$fixed)
On the natural scale, model fixed effects parameter estimates are as follows:
models$natural_scale_das_d
We calculated Bayes factors to evaluate the strength of evidence in support of a null effect the fixed effects of total hours played and time (pre- and post-lockdown) and their interaction.
hypotheses$das_d
We found overwhelming evidence in support of the null model in comparison to the alternative for the main effect of total hours played and the interaction between total hours played (both BF01 >=99). However, we found strong evidence in support of a main effect of time on depression, BF10= 48.751781. This supports the notion that post-lockdown measures of depression were higher than pre-lockdown measures.
as.data.frame(models$das_a$fixed)
On the natural scale, model fixed effects parameter estimates are as follows:
as.data.frame(models$natural_scale_das_a)
We calculated Bayes factors to evaluate the strength of evidence in support of a null effect the fixed effects of total hours played and time (pre- and post-lockdown) and their interaction.
hypotheses$das_a
We found overwhelming evidence in support of the null model in comparison to the alternative for all main effects and interactions (all BF01 >= 16). Thus, the data are more likely under the null than the alternative model.
as.data.frame(models$das_s$fixed)
On the natural scale, model fixed effects parameter estimates are as follows:
as.data.frame(models$natural_scale_das_s)
We calculated Bayes factors to evaluate the strength of evidence in support of a null effect the fixed effects of total hours played and time (pre- and post-lockdown) and their interaction.
hypotheses$das_s
Here, we found storng evidence against an effect of time on stress (BF01 = 9.7938507), and overwhelming evidence against an effect of total hours played and the interaction between time and total hours played on stress (both BF01 > 394).
We next explored the effect of the change in total hours playing games before and after lockdown on the difference in mental health outcomes pre- and post-lockdown. Here, hours played after were subtracted from hours played before, and DAS outcomes after were (separately) subtracted from DAS outcomes before.
Models were again fitted separately for each subscale in brms using the brm function. Here, the data were fitted using a Gaussian model (identity link function), with the fixed effect of difference in hours played. Models used a \(Normal(0, 5)\) prior on the intercept, a \(Normal(0, 1)\) prior on the slope term, and an \(Exponential(1)\) prior on the sigma term.
Again, the presence of an effect of difference in hours played was evaluated using Bayes factors calculated using the Savage-Dickey density ratio. We also present the fixed effects for these models on the natural scale.
We present posterior predictions for the effect of difference in hours played pre- and post-lockdown on differences in outcomes for each subscale. Here, lines represent the posterior median along with 50%, 80%, and 95% credible intervals (shaded).
knitr::include_graphics(plots_dir[str_detect(plots_dir, "das_diff.png")])
as.data.frame(models$das_d_diff$fixed)
as.data.frame(models$das_a_diff$fixed)
as.data.frame(models$das_s_diff$fixed)
as.data.frame(models$das_l_d_diff$fixed)
as.data.frame(models$das_l_a_diff$fixed)
as.data.frame(models$das_l_s_diff$fixed)
Posterior predictive checks were carried out for all fitted models. These show a relatively good fit for each model whereby draws from the posterior are close to the fitted data. This indicates good model fit.
knitr::include_graphics(plots_dir[str_detect(plots_dir, "pp_check_das_d.png")])
knitr::include_graphics(plots_dir[str_detect(plots_dir, "pp_check_das_d_diff.png")])
knitr::include_graphics(plots_dir[str_detect(plots_dir, "pp_check_das_a.png")])
knitr::include_graphics(plots_dir[str_detect(plots_dir, "pp_check_das_a_diff.png")])
knitr::include_graphics(plots_dir[str_detect(plots_dir, "pp_check_das_s.png")])
knitr::include_graphics(plots_dir[str_detect(plots_dir, "pp_check_das_s_diff.png")])